const { app, BrowserWindow, Menu } = require("electron");

if (require("electron-squirrel-startup")) {
  return app.quit();
}
const WinState = require("electron-win-state").default;
const path = require("path");
require("./ipc/ipcmian");
const createWindow = async () => {
  const winState = new WinState({
    defaultWidth: 1800,
    defaultHeight: 1600,
  });
  const win = new BrowserWindow({
    ...winState.winOptions,
    webPreferences: {
      nodeIntegration: true,
      preload: path.join(__dirname, "/ipc/preload.js"),
    },
  });
  win.setTitle("抖音服务商商家管理代开发管理平台");
  win.webContents.openDevTools()
  win.on("close", (e) => {
    win.hide();
    win.setSkipTaskbar(true);
    e.preventDefault();
  });

  win.loadURL("http://localhost:5173/");
  winState.manage(win);
};

const template = [];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);

app.whenReady().then(async () => {
  createWindow();
  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0) createWindow();
  });
});
